 <template>
  <div>
    <el-container v-loading="loading">
      <el-header>
        <div class="el-header-left">
          <img src="../assets/image/xj_logo2.jpg" alt="LOGO" class="logo" />
          <h3 class="f-w-n fontsize-20 space-lt">房屋管理平台</h3>
          <i class="el-icon-s-fold fontsize-22 f-w-n"></i>
        </div>
        <div class="loginInfo">
          <el-avatar icon="el-icon-user-solid"></el-avatar>
          <el-dropdown trigger="click">
            <span class="el-dropdown-link">
              {{ user_name
              }}<i class="el-icon-arrow-down el-icon-caret-bottom"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item icon="el-icon-key">修改密码</el-dropdown-item>
              <!-- 这里受到组件影响，点击时需要加上native来强制触发事件 -->
              <el-dropdown-item
                icon="el-icon-switch-button"
                divided
                @click.native="loginout"
                >退出登录</el-dropdown-item
              >
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu
            default-active="1"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
            background-color="#e3e3e3"
            text-color="#000"
            active-text-color="#0e7de6"
          >
            <el-menu-item index="1">
              <i class="el-icon-menu"></i>
              <span slot="title">首页</span>
            </el-menu-item>
            <el-menu-item index="2">
              <i class="el-icon-menu"></i>
              <span slot="title">房屋管理</span>
            </el-menu-item>
            <el-submenu index="3">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>缴纳管理</span>
              </template>
              <el-menu-item index="3-1">缴纳记录</el-menu-item>
              <el-menu-item index="3-2">催缴清单</el-menu-item>
            </el-submenu>
            <el-submenu index="4">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>缴纳统计</span>
              </template>
              <el-menu-item index="4-1">当日缴费统计</el-menu-item>
              <el-menu-item index="4-2">月缴费统计</el-menu-item>
              <el-menu-item index="4-3">月追缴欠费统计</el-menu-item>
              <el-menu-item index="4-4">年欠费统计</el-menu-item>
            </el-submenu>
            <el-submenu index="5">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>系统设置</span>
              </template>
              <el-menu-item index="5-1">账期设置</el-menu-item>
              <el-menu-item index="5-2">小区设置</el-menu-item>
              <el-menu-item index="5-3">减免项设置</el-menu-item>
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main>Main</el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
export default {
  data() {
    return {
      user_name: '',
      loading: false
    }
  },
  created() {
    this.user_name = sessionStorage.getItem('username')
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath)
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath)
    },
    loginout() {
      console.log(111)
       loading: true
      this.$confirm('您确定退出当前系统吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
            //退出成功之后清楚token值
            sessionStorage.clear();
          this.$message({
            type: 'success',
             message: '退出成功!',
            
          });
           loading: false
          //编程式导航添加路由地址
          this.$router.push('/login')
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消操作',
          })
        })
    },
  },
}
</script>
<style lang="less" scoped>
.el-container {
  height: 100%;
  background-color: #f4f4f4;
}
.el-header {
  background-color: #0e7de6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
}
.el-header-left {
  width: 250px;
  display: flex;
  align-items: center;
  //   justify-content: space-between;   挤到右边
}
.el-header-left h3 {
  margin: 0 15px;

  color: #fff;
}
.el-avatar {
  height: 28px;
  width: 28px;
  line-height: 28px;
  cursor: pointer;
}

.el-aside {
  // background-color: red;
  width: 300px;
  height: 3000px;
  background-color: #e3e3e3;
}
.el-main {
  background-color: #fff;
}
.logo {
  width: 40px;
  border-left: solid 6px white;
  border-right: solid 6px white;
}
.loginInfo {
  clear: both;
}
.loginInfo i {
  cursor: pointer;
  font-size: 28px !important;
  border-radius: 50%;
  vertical-align: middle;
  transform: translate(0px, -2px);
}
.el-popper {
  margin-top: 15px !important;
}
.el-dropdown {
  margin: 0 20px;
}

.el-dropdown-link {
  cursor: pointer;
  color: #fff !important;
}
.el-icon-arrow-down {
  font-size: 12px;
}
.demonstration {
  display: block;
  color: #8492a6;
  font-size: 14px;
  margin-bottom: 20px;
}
.loginInfo {
  display: flex;
  align-items: center;
}
</style> 